import SparkMD5 from 'spark-md5';
export function createChunk(file: File, index: number, chunkSize: number) {
  return new Promise((resolve, reject) => {
    const start = index * chunkSize;
    const end = start + chunkSize;
    const spark = new SparkMD5.ArrayBuffer();
    const reader = new FileReader();
    reader.onload = function (e) {
      spark.append(e.target?.result as ArrayBuffer);
      resolve({
        start,
        index,
        hash: spark.end(),
        end,
      });
    };
    reader.readAsArrayBuffer(file.slice(start, end));
  });
}
